﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Dual licensed under the MIT and GPL licenses:
//  http://www.opensource.org/licenses/mit-license.php
//  http://www.gnu.org/licenses/gpl.html

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace DNA.Mvc.jQuery
{
    [Obsolete]
    public abstract class DataBindableComponentContainer<TComponent> : ContainerViewComponent<TComponent>
        where TComponent : ViewComponent
    {
        private Action<TComponent> itemDataBoundTemplate;

        public Action<IDictionary<string, object>> ItemDataBoundAttributes { get; set; }

        public Action<TComponent> ItemDataBoundTemplate
        {
            get { return itemDataBoundTemplate; }
            set { itemDataBoundTemplate = value; }
        }

        public override void RenderContent(System.Web.UI.HtmlTextWriter writer)
        {
            foreach (var item in InnerItems)
                if (ItemDataBoundTemplate != null)
                    ItemDataBoundTemplate.Invoke(item);
                else
                    item.Render(writer);
        }
    }


}

